#include "cgraphics.hpp"

void CGraphics::Init(HWND hWnd)
{
	this->D3D = Direct3DCreate9(D3D_SDK_VERSION);

	ZeroMemory(&this->D3DPP, sizeof(this->D3DPP));
	this->D3DPP.Windowed		= TRUE;
	this->D3DPP.SwapEffect		= D3DSWAPEFFECT_DISCARD;
	this->D3DPP.hDeviceWindow	= hWnd;

	this->D3D->CreateDevice(D3DADAPTER_DEFAULT,
							D3DDEVTYPE_HAL,
							hWnd,
							D3DCREATE_SOFTWARE_VERTEXPROCESSING,
							&this->D3DPP,
							&this->D3DDevice);
}

void CGraphics::Render()
{
	this->D3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
	this->D3DDevice->BeginScene();
	//----------------------
	// Render Mich

	// Render Mich
	//----------------------
	this->D3DDevice->EndScene();
	this->D3DDevice->Present(NULL, NULL, NULL, NULL);
}

void CGraphics::Clean()
{
	this->D3D->Release();
	this->D3DDevice->Release();
}